# encoding=utf-8

import sqlite3 as sql


def conn():
    connection = sql.connect('test.db')
    cursor = connection.cursor()
    return cursor


def getData():
    conn().execute('select * from user where id =?', ('1',))
    values = conn().fetchall()
    print(values)
    conn().close()


def initData():
    conn().execute('create table user(id varchar(20) primary key,name varchar(20))')
    conn().execute('insert into user(id,name) values (\'1\',\'Mike\')')
    print(conn().execute('select * from user where id =?', ('1',)))
    conn().close()


if __name__ == '__main__':
    initData()
    getData()
